package com.hdax.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResponse<T> {
    private Integer code;
    private String msg;
    private T data;
    private Long count;

    //成功响应(有分页)
    public CommonResponse(T data, Long count) {
        this.code = 0;
        this.msg = "success";
        this.data = data;
        this.count = count;
    }

    //成功响应(无分页)
    public CommonResponse(T data) {
        this.code = 0;
        this.msg = "success";
        this.data = data;
    }

    //响应失败
    public CommonResponse(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
